<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Route::get('/', function () { return view('welcome'); });

//首先引入
use App\Http\Controllers\IndexController;
Route::get('/', [IndexController::class, 'index']);
Route::get('sendsubscribeemail', [IndexController::class, 'sendsubscribeemail']);//订阅发邮件
Route::get('addqueuesubscribe', [IndexController::class, 'addqueuesubscribe']);//订阅发邮件者添加到队列

use App\Http\Controllers\CatController;
Route::redirect('/cat/', '/cat/36');
Route::get('cat/{cid}', [CatController::class, 'show']);

use App\Http\Controllers\ArtController;
Route::get('art/{aid}', [ArtController::class, 'show']);
//Route::post('art/comment', [ArtController::class, 'comment']);

// 只有认证过的用户可以进入
// 使用auth中间件
Route::middleware(['auth'])->group(function () {
    Route::post('art/comment', [ArtController::class, 'comment']);//评论
    Route::post('art/dianzan', [ArtController::class, 'dianzan']);//点赞

    Route::post('subscribe', [IndexController::class, 'subscribe']);//订阅
});


use App\Http\Controllers\TestController;
Route::resource('test', TestController::class)->only([
    'index', 'show'
]);
Route::resource('test', TestController::class)->except([
    'create', 'store', 'update', 'destroy'
]);


Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
    return view('dashboard');
})->name('dashboard');

